-
Notifications
You must be signed in to change notification settings - Fork 69
Master add shortcuts matho #7536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
0130936 to
945f5c2
Compare
old tests did not actually test the shortcuts functionality there was nothing asserted Task : 5231802
shift+F11 (new sheet), ctrl+enter (fill range) and alt+t (new table) Task: 5231802
945f5c2 to
ba72476
Compare
hokolomopo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello 👋
Reading the spec of the task, you didn't do Insert row/column, was that discussed with francois ? And Insert Comment, but that's odoo specific.
Also the spec mentions showing the shortcuts in Odoo's ctrl+k menu, but I'm for doing it in another task.
| bottom: multipleRowsInSelection ? zone.top : zone.top - 1, | ||
| top: multipleRowsInSelection ? zone.top : zone.top - 1, | ||
| }; | ||
| this.originSheetId = this.getters.getActiveSheetId(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
allowDispatch should not change the state of the plugin. and this.originSheetId is not used here anyway
same comment for copy on left/copy on zone
| const { INSERT_TABLE } = require("../../src/actions/menu_items_actions"); | ||
| expect(INSERT_TABLE as jest.Mock).toHaveBeenCalled(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd remove this (and the jest.mock("../../src/actions/menu_items_actions.ts" at top of the file), you already tested that a table was inserted.
In general avoid mocking imports unless absolutely necessary. It makes tests harder to understand, and breaks if we ever move files around.
Testing what the result of an action is is the superior option over testing expect(helper).toHaveBeenCalled() anyway. Testing that the helper has been called doesn't actually test much, the helper could be broken and not do anything, and the test wouldn't notice. Just test that a table was inserted, and it's enough 🙂
| }); | ||
|
|
||
| test("can copy and paste cell(s) on left using CTRL+R", async () => { | ||
| test("banane", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🍌 🍌 🍌
| // @ts-ignore | ||
| const notificationStore = env.__spreadsheet_stores__.get(NotificationStore); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid ts-ignore when possible. I'm guessing env.getStore(NotificationStore) doesn't work because of the proxy ? Otherwise you could create a mock raiseError function and give it to the env (see raiseError tests in bottom_bar_component.test.ts)
| expect( | ||
| fixture.querySelector(".o-menu .o-menu-item[data-name='insert_link']")?.textContent | ||
| fixture.querySelector(".o-menu .o-menu-item[data-name='insert_link'] .o-menu-item-name") | ||
| ?.textContent | ||
| ).toBe("Insert link"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: expect(".o-menu .o-menu-item[data-name='insert_link'] .o-menu-item-name").toHaveText("Insert link")
see our custom jest matchers in jest_extend.ts
| notificationStore.updateNotificationCallbacks({ | ||
| notifyUser: mockEnv.notifyUser || (() => {}), | ||
| raiseError: mockEnv.raiseError || (() => {}), | ||
| raiseError: mockEnv.raiseError || (jest.fn() as unknown as (message: string) => void), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As i said in a previous comment, pass a mocked raiseError to the env instead (mockEnv.raiseError)

Description:
Add some shortcuts
Task: 5231802
review checklist